home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Auge 4000 / Auge 4000 #47 (1990-06-22)(Amiga User Gruppe Einzugsgebiet 4000).zip / Auge 4000 #47 (1990-06-22)(Amiga User Gruppe Einzugsgebiet 4000).adf / arp-pro1.3 / LATTICE / latticeglue.a < prev   
Text File  |  1990-06-22  |  6KB  |  199 lines

  1. *************************************************************************
  2. *                                    *
  3. * 4/26/89    LatticeGlue.a    by MKSoft                *
  4. *                                    *
  5. *************************************************************************
  6. *                                    *
  7. *    AmigaDOS Resource Project -- Lattice Library Glue Code        *
  8. *                                    *
  9. *************************************************************************
  10. *                                    *
  11. *    Copyright (c) 1989 by MKSoft    For arp.library v39        *
  12. *                                    *
  13. *    With some ideas from V35 glue by JToebes            *
  14. *                                    *
  15. *    The arp.library, and related code and files may be freely used    *
  16. *    by supporters of ARP.  Modules in the arp.library may not be    *
  17. *    extracted for use in independent code, but you are welcome to    *
  18. *    provide the arp.library with your work and call on it freely.    *
  19. *                                    *
  20. *    You are equally welcome to add new functions, improve the ones    *
  21. *    within, or suggest additions.                    *
  22. *                                    *
  23. *    BCPL programs are not welcome to call on the arp.library.    *
  24. *    The welcome mat is out to all others.                *
  25. *                                    *
  26. *************************************************************************
  27. *                                    *
  28. *    This file will assembly with the Lattice assembler that comes    *
  29. *    as part of the Lattice 5.0 product.                *
  30. *                                    *
  31. *    To assemble the LARGE_CODE version USE:                *
  32. *        ASM -iINCLUDE: -dLARGE_CODE LatticeGlue.a        *
  33. *                                    *
  34. *    To assemble the SMALL_CODE version USE:                *
  35. *        ASM -iINCLUDE: -dSMALL_CODE LatticeGlue.a        *
  36. *                                    *
  37. *************************************************************************
  38. *
  39. *    We need to include some definitions...
  40. *
  41.     IFND    EXEC_TYPES_I
  42.     INCLUDE    "EXEC/Types.i"
  43.     ENDC
  44. *
  45.     IFND    EXEC_EXECBASE_I
  46.     INCLUDE    "EXEC/EXECbase.i"
  47.     ENDC
  48. *
  49.     IFND    LIBRARIES_DOSEXTENS_I
  50.     INCLUDE    "Libraries/DOSextens.i"
  51.     ENDC
  52. *
  53.     IFND    LIBRARIES_ARPBASE_I
  54.     INCLUDE    "Libraries/ARPbase.i"
  55.     ENDC
  56. *
  57. *************************************************************************
  58. *
  59. *    External reference will be made to _ArpBase...
  60. *
  61.         xref        _ArpBase
  62. *
  63. *************************************************************************
  64. *
  65. *    Define the section as code...
  66. *
  67.         section        "LatticeGlue",code
  68. *
  69. *************************************************************************
  70. *
  71. * Some macros to help with the work...
  72. *
  73. GLUE_DEF    MACRO
  74.         xdef        _\1
  75. _\1:
  76. THIS_LIB    SET        _LVO\1        ; Set the arp offset to call
  77.         ENDM
  78. *
  79. *************************************************************************
  80. *
  81. *    Set SMALL_CODE=1 for a4 addressing...
  82. *    Set LARGE_CODE=1 for absolute addressing...
  83. *    if niether, just cause an error...
  84. *
  85. CALL_ARP    MACRO
  86.         move.l        a6,-(sp)    ; Save a6...
  87.         IFD        SMALL_CODE
  88.         move.l        _ArpBase(a4),a6    ; If a4 addressing....
  89.         ENDC
  90.         IFD        LARGE_CODE
  91.         move.l        _ArpBase,a6    ; If not a4 addressing...
  92.         ENDC
  93.         IFND        SMALL_CODE
  94.         IFND        LARGE_CODE
  95.         moveq.l        #12323,a0    ; Cause an error!
  96.         ENDC
  97.         ENDC
  98.         jsr        THIS_LIB(a6)
  99.         move.l        (sp)+,a6
  100.         ENDM
  101. *
  102. *************************************************************************
  103. *
  104. *    Now for the Printf... etc has to be done via glue since
  105. *    it has a variable number of parameters...
  106. *
  107.         GLUE_DEF    Printf        ; The Printf glue...
  108.         move.l        4(sp),a0
  109.         lea.l        8(sp),a1
  110.         CALL_ARP
  111.         rts                ; return...
  112. *
  113.         GLUE_DEF    FPrintf        ; Now, for the FPrintf glue...
  114.         movem.l        4(sp),d0/a0
  115.         lea.l        12(sp),a1
  116.         CALL_ARP
  117.         rts
  118. *
  119.         GLUE_DEF    SPrintf        ; Same for SPrintf...
  120.         movem.l        4(sp),d0/a0
  121.         lea.l        12(sp),a1
  122.         CALL_ARP
  123.         rts
  124. *
  125. *************************************************************************
  126. *    Now come some of the trackers...  Note that the tracker in    *
  127. *    IoErr() will be invalid if the return is NULL            *
  128. *************************************************************************
  129. *
  130.         GLUE_DEF    ArpOpen        ; Tracked Open()
  131.         movem.l        4(sp),d1/d2
  132.         CALL_ARP
  133.         bra.s        Check_Save    ; Save tracker...
  134. *
  135.         GLUE_DEF    ArpOpenLibrary    ; Tracked OpenLibrary()
  136.         movem.l        4(sp),d0/a1
  137.         CALL_ARP
  138.         bra.s        Check_Save    ; Save tracker...
  139. *
  140.         GLUE_DEF    ArpLock        ; Tracked Lock()
  141.         movem.l        4(sp),d1/d2
  142.         CALL_ARP
  143.         bra.s        Check_Save    ; Save tracker...
  144. *
  145.     GLUE_DEF    ArpAllocFreq        ; Last minute addition
  146.     CALL_ARP
  147.     bra.s    Check_Save
  148. *
  149.         GLUE_DEF    ArpDupLock    ; Tracked DupLock()
  150.         move.l        4(sp),d1
  151.         CALL_ARP            ; Drop into Check_Save...
  152. *
  153. *************************************************************************
  154. *    This does the voodoo of saving the a1 register into IoErr()    *
  155. *    This was put in the middle as to make sure all relative        *
  156. *    branches will reach it...                    *
  157. *************************************************************************
  158. *
  159. Check_Save:    tst.l        d0        ; Check for return error...
  160.         beq.s        Exit_Save    ; If error, skip setting...
  161. Save_Second:    move.l        4,a0
  162.         move.l        ThisTask(a0),a0
  163.         move.l        a1,pr_Result2(a0)
  164. Exit_Save:    rts
  165. *
  166. *************************************************************************
  167. *    Now, with some more bindings...    ( Not the skiing type :-( )    *
  168. *************************************************************************
  169. *
  170.         GLUE_DEF    ArpAllocMem    ; Tracked AllocMem()
  171.         movem.l        4(sp),d0/d1
  172.         CALL_ARP
  173.         bra.s        Check_Save    ; Save tracker...
  174. *
  175.         GLUE_DEF    RListAlloc    ; ResList allocate...
  176.         move.l        4(sp),a0
  177.         move.l        8(sp),d0
  178.         CALL_ARP
  179.         bra.s        Save_Second    ; Save tracker...
  180. *
  181. *************************************************************************
  182. *    This gets a tracker and then, from the argument passed, puts    *
  183. *    the ID into it.  While the ID is a WORD, for calling reasons    *
  184. *    the binding/prototype uses a LONG.  (680x0 stack alignment...)    *
  185. *************************************************************************
  186. *
  187.         GLUE_DEF    GetTracker    ; Get Tracker (With ID)
  188.         CALL_ARP
  189.         beq.s        No_Tracker    ; No tracker, ERROR!
  190.         move.w        6(sp),dt_ID(a1)    ; Save ID  (It was LONG)
  191. No_Tracker:    move.l        a1,d0        ; Put into return register
  192.         bra.s        Save_Second    ; Also save it...
  193. *
  194. *************************************************************************
  195. *    And, there you have it.  Now you too can call on ARP.        *
  196. *************************************************************************
  197. *
  198.         END
  199.